package ObjectMethod;

public class EqualTest {
    public static void main(String[] args) {
        Person abc = new Person("abc", 18);
    
        Person xyz = new Person("abc", 18);
        
        // abc/xyz 保存的是对象的内存地址，因为是两个对象，地址不同。
        if (abc == xyz){
            System.out.println("equal");
        }
        else {
            System.out.println("not equal");
        }
    
    
        Person person = new Person("kevin", 20);
        Person p1 = person;
        Person p2 = person;
    
        if (p1 == p2){
            System.out.println("equal");
        }
        else {
            System.out.println("not equal");
        }
    
        if (abc.equals(xyz)){
            System.out.println("equal");
        }
        else {
            System.out.println("not equal");
        }
    }
}
